#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

int map[510][510];
int dis[510][510];
int mov[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
queue<int> q;
int n, m;
int s, t;

int bfs(int s, int t)
{
    while (!q.empty())
        q.pop();   //没有clear()方法 好制杖
    q.push(s);
    while (!q.empty())
    {
        int tmp = q.front();
        q.pop();
        int x = tmp / m, y = tmp % m;
        for (int i = 0; i < 4; i++)
        {
            int dx = x + mov[i][0];
            int dy = y + mov[i][1];
            if (map[dx][dy] == 0)
                continue;
            if (dis[dx][dy] != 0)
                continue;
            if (dx * m + dy == t)
                return 1;
            dis[dx][dy] = dis[dx][dy] + 1;
            q.push(dx * m + dy);
        }
    }
    return 0;
}

int main()
{
    while (cin >> n >> m)
    {
        memset(map, 0, sizeof(map));
        memset(dis, 0, sizeof(dis));
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
            {
                char c;
                scanf(" %c", &c);
                if (c == 'S')
                {
                    s = i * m + j;
                    map[i][j] = 1;
                }
                else if (c == 'E')
                {
                    t = i * m + j;
                    map[i][j] = 1;
                }
                else if (c == '.')
                {
                    map[i][j] = 1;
                }
                else if (c == '#')
                {
                    map[i][j] = 0;
                }
            }
        if (bfs(s, t))
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}